package com.dbm.model;

import org.apache.log4j.Logger;
/**
 * 向ctl发起 http 请求工具类 
 * @author wqying
 *
 */
public class CtlHttp {
	private ModelProp prop = new ModelProp();
	private HttpRequest httpRequest = new HttpRequest();
	Logger log = Logger
			.getLogger(CtlHttp.class);
	/**
	 * 向ctl发送http请求调用方法
	 * @param param    请求参数
	 * @return
	 * @throws Exception
	 */
	public synchronized String getHttpResult(String param) throws Exception{
		String url = prop.getCtlUrl();
		log.info(url+"?"+param);
		String result = httpRequest.sendPost(url, param);
		if(!(result.indexOf("<response>")>0)){
			result="<?xml version=\"1.0\" encoding=\"utf-8\"?><response><flag>failure</flag><code>qimen-error</code><message>"+result+"</message></response>"; 
		}
		return result;
	}
}
